<?php
/**
 * Created by Dumitru Russu
 * User: developer
 * Date: 8/1/12
 * Time: 10:45 AM
 */
class Debug {
    private $configVars = array();
    private $constantVars;

    /**
     * Construct function
     */
    public function __construct() {
		/**
		 * Assign Vars to display in the debug Variables
		 */
        $this->configVars['_POST'] = $_POST;
        $this->configVars['_GET'] = $_GET;
		$this->configVars['_FILES'] = $_FILES;
        $this->configVars['_SERVER'] = $_SERVER;
    }

    public function addPrivateVar() {
		$args = func_get_args();
		if (is_array($args) && count($args) > 0) {
			foreach ($args as $privateVar) {
				$this->configVars['_PRIVATE'][] = $privateVar;
			}
		}
    }

    public function displayDebug($executionTime = 0) {
		$this->constantVars = get_defined_constants(true);
		$this->configVars['_COOKIE'] = $_COOKIE;
		if (!defined('CLI')) {
  			$this->configVars['_SESSION'] = Engine::$S->Get();
		}
		$this->configVars['_CONSTANTS'] = $this->constantVars['user'];
		$dbQueries = MySQL::$allQueries;
		$dbQueriesNr = MySQL::$queriesNr;
		$dbQueriesTime = MySQL::$queriesTime;
		Engine::$TPL->assign('configVars', $this->configVars);
		Engine::$TPL->assign('executionTime', $executionTime);
		Engine::$TPL->assign('dbQueries', $dbQueries);
		Engine::$TPL->assign('dbQueriesNr', $dbQueriesNr);
		Engine::$TPL->assign('dbQueriesTime', $dbQueriesTime);
		return Engine::$TPL->display('debug', true);
    }
}